	@* DXCOMMENT: Configure GridView *@

	@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "GridView";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartialView" };

        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        settings.SettingsPager.Visible = true;
        settings.SettingsPager.PageSize = 30;
        settings.Settings.ShowVerticalScrollBar = true;
        settings.Settings.VerticalScrollableHeight = 800;
        //settings.Settings.VerticalScrollBarStyle = GridViewVerticalScrollBarStyle.Virtual;
        settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
		
		// DXCOMMENT: Configure grid's columns in accordance with data model fields
        settings.Columns.Add("FileName");
        settings.Columns.Add("HireDate").PropertiesEdit.DisplayFormatString = "d";
        settings.Columns.Add("LastName");
        settings.Columns.Add("FirstName");
        settings.Columns.Add("StoreID", "Store");
        settings.Columns.Add("ADPNumber");
        settings.Columns.Add("TermDate").PropertiesEdit.DisplayFormatString = "d";

        settings.Settings.ShowFilterRow = true;
        settings.KeyFieldName = "ADPNumber";

        foreach (var column in settings.Columns)
        {
            ((MVCxGridViewColumn)column).Settings.AutoFilterCondition = AutoFilterCondition.Contains; 
        }
        
        settings.SettingsDetail.ShowDetailRow = true;
        
        settings.SetDetailRowTemplateContent(c =>
        {
            ViewContext.Writer.Write("<div style=\"width: 100%; text-align: center; overflow: auto;\">");
            ViewContext.Writer.Write("<div>Page:");

            for (int i = 0; i < I9DocumentViewer.Helpers.ImageHelpers.GetI9ImageCount((string)DataBinder.Eval(c.DataItem, "FileName")); i++)
                ViewContext.Writer.Write("<button onclick=\"swapI9Image($('#I9DocumentImage" + c.VisibleIndex + "'), " + i + ")\" style=\"background: none; border: none; cursor: pointer;\">" + (i + 1) + "</button>");
            
            ViewContext.Writer.Write("</div>");
            ViewContext.Writer.Write("<img id=\"I9DocumentImage" + c.VisibleIndex + "\"src=\"" + Url.Action("I9Document", "home", new { imageName = DataBinder.Eval(c.DataItem, "FileName"), page = 0 }) + "\" style=\"width: 100%;\" alt=\"\" />");
            ViewContext.Writer.Write("</div>");
        });
        
    }).Bind(Model).GetHtml()

<script type="text/javascript">
    function swapI9Image(image, page) {
        var src = image.attr('src');
        var baseURL = src.substring(0, src.lastIndexOf('=') + 1);

        image.attr('src', baseURL + page);
    }
</script>